﻿using System;
using System.Collections.Generic;
using System.Text;
using VietKinsNutrition.Data;
using VietKinsNutrition.Common;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Views.Grid;
using System.Windows.Forms;

namespace VietKinsNutrition.Bussiness
{
    public class ClsTbl_LoaikienthucnoitroBLL : ClsBindingBLL
    {
        private int _id;
        public int Id
        {
            get { return _id; }
            set { _id = value; }
        }
        ClsTblDm_LoaikienthucnoitroDAL ClsTblDm_Loaikienthucnoitrodal = new ClsTblDm_LoaikienthucnoitroDAL();
        public void Bind_GirdView(GridView Grid)
        {
            Grid.GridControl.DataSource = this.ClsTblDm_Loaikienthucnoitrodal.SelectAll();
        }
        public void Bind_Combo(ComboBoxEdit Cbo)
        {
            UserComboBoxItem.SetItem(Cbo, this.ClsTblDm_Loaikienthucnoitrodal.SelectAll(), "Id", "Tenloaikienthucnoitro");
            //Cbo.DisplayMember = ;
            //Cbo.ValueMember = ;
        }
        public void ClearControl(TextBox TextBox)
        {
            TextBox.Text = "";
        }
        public void FocusControl(TextBox Textbox, DataGridView Grid)
        {
            Textbox.Focus();
            Grid.Enabled = !Grid.Enabled;
        }

        public void BingSource_InputControl(TextBox Textbox, DataGridView Grid)
        {
            if (Grid.RowCount > 0)
            {
                this.Id = int.Parse(Grid.Rows[Grid.CurrentRow.Index].Cells["Id"].Value.ToString());
                Textbox.Text = Grid.Rows[Grid.CurrentRow.Index].Cells["Tenloaikienthucnoitro"].Value.ToString();
            }
        }
        public void Insert(string Ten)
        {
            ClsTblDm_Loaikienthucnoitrodal.Insert(Ten);
        }
        public void Edit(int Id, string Ten)
        {
            ClsTblDm_Loaikienthucnoitrodal.Edit(Id, Ten);
        }
        public void Del()
        {
            ClsTblDm_Loaikienthucnoitrodal.Del(Id);
        }
    }
}
